import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'

const layout = () => import('../views/layouts/index.vue')

// 人员管理
const person = () => import('../views/person/index.vue')

// 系统工具
const tools = () => import('../views/tools/index.vue')
// 全局变量
const personSearch = () => import('../views/tools/person-search.vue')
// 请求响应
const requestAndRespone = () => import('../views/tools/request-response.vue')
// 本地缓存
const localCache = () => import('../views/tools/local-cache.vue')
// 工具函数
const toolFunction = () => import('../views/tools/tool-function.vue')

// 基础页面
const basePage = () => import('../views/base-page/index.vue')
// 登录页面
const loginPage = () => import('../views/base-page/login-page.vue')
// 注册页面
const registerPage = () => import('../views/base-page/register-page.vue')
const routes: Array<RouteRecordRaw> = [
    {
        path: '/',
        name: 'index',
        component: layout,
        redirect: '/index',
        meta: { title: '首页' },
        children: [
            {
                path: 'index',
                name: 'index',
                component: person,
                meta: { title: '快速上手' }
            },
            {
                path: 'tools',
                name: 'personSearch',
                redirect: '/tools/person-search',
                meta: { title: '系统工具' },
                component: tools,
                children: [
                    {
                        path:'/tools/person-search',
                        name: 'personSearch',
                        component: personSearch,
                        meta: { title: '全局变量' }
                    },
                    {
                        path:'/tools/request-response',
                        name: 'requestAndResponse',
                        component: requestAndRespone,
                        meta: { title: '请求响应' }
                    },
                    {
                        path:'/tools/local-cache',
                        name: 'localCache',
                        component: localCache,
                        meta: { title: '本地缓存' }
                    },
                    {
                        path:'/tools/tool-function',
                        name: 'toolFunction',
                        component: toolFunction,
                        meta: { title: '工具函数' }
                    }
                ]
            },
            {
                path: 'base-page',
                name: 'loginPage',
                redirect: '/base-page/login-page',
                component: basePage,
                meta: { title: '基础页面' },
                children: [
                    {
                        path:'/base-page/login-page',
                        name: 'loginPage',
                        component: loginPage,
                        meta: { title: '登录页面' }
                    },
                    {
                        path:'/base-page/register-page',
                        name: 'registerPage',
                        component: registerPage,
                        meta: { title: '注册页面' }
                    }
                ]
            },
            
        ]
    }
]
const router = createRouter({
    history: createWebHistory(),
    routes
})

export default router
